import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ThingsModelTemplateVO, ThingsModelTemplateForm, ThingsModelTemplateQuery } from '@/api/iot/thingsModelTemplate/types';

/**
 * 查询物模型模板列表
 * @param query
 * @returns {*}
 */

export const listThingsModelTemplate = (query?: ThingsModelTemplateQuery): AxiosPromise<ThingsModelTemplateVO[]> => {
  return request({
    url: '/iot/thingsModelTemplate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物模型模板详细
 * @param templateId
 */
export const getThingsModelTemplate = (templateId: string | number): AxiosPromise<ThingsModelTemplateVO> => {
  return request({
    url: '/iot/thingsModelTemplate/' + templateId,
    method: 'get'
  });
};

/**
 * 新增物模型模板
 * @param data
 */
export const addThingsModelTemplate = (data: ThingsModelTemplateForm) => {
  return request({
    url: '/iot/thingsModelTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 修改物模型模板
 * @param data
 */
export const updateThingsModelTemplate = (data: ThingsModelTemplateForm) => {
  return request({
    url: '/iot/thingsModelTemplate',
    method: 'put',
    data: data
  });
};

/**
 * 删除物模型模板
 * @param templateId
 */
export const delThingsModelTemplate = (templateId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/thingsModelTemplate/' + templateId,
    method: 'delete'
  });
};
